#This is a further look at measures of central tendency # We want to generate the values in the given tables. # First, we should bring the gnrnd4 program into our # environment. source("../gnrnd4.R") # then we can generate the values gnrnd4(1845678904, 12800649) # now, print out the values so that we can check to be # sure that we have generated the correct values L1 # Then, we can find the mean and median of the data mean( L1 ) median(L1) # There is something that we want to notice about the # mean and the median. If we change a value in the list # to be an extreme value, that is far different from the # rest of the values, a real outlier, then we will change # mean by a lot bit we will not change teh median much at all. # We will change the 77.8 that is the 16th value in the # list to be 778 (perhaps it was just a typing error where # we dropped the decimal point). L1[ 16 ] <- 778 # Let us look at L1 again to see that change L1 # now look at the mean and median and see how much they changed mean( L1 ) median(L1) # Then, we will look at a different aspect of the mean. # In particular, if we have a large set of data, then # it is really hard to change the mean by a lot just by # adding more values at the upper or lower ends to the existing # data # First we will load the gnrnd5 function. source("../gnrnd5.R") # Then we will generate a large collection of data gnrnd5( 177083055604, 345005678) # That generated 557 values, lets look at the # first 10 and then at the last 8 head( L1, 10 ) tail( L1, 8 ) # now look at the mean mean( L1 ) # now, add 10 values, all down in the 450 to 500 range # first, combine the 10 new values in a variable called L2 L2 <- c( 456, 487, 476, 459, 497, 481, 463, 482, 477, 489) # just as a point of interest, find the mean of # these new values mean(L2) # this is really different from the mean of the L1 values # then combine L1 and L2 to make L3 L3 <- c( L1, L2 ) # note, in the environment area, that L3 now has 567 values # find the mean of L3 mean( L3 ) # see how different it is from the 568.1034 mean of L1